package com.weijun.keepalive_daemon.service

import android.app.job.JobParameters
import android.app.job.JobService
import android.content.Intent
import android.os.Build
import com.weijun.keepalive_daemon.DaemonKeepAlive
import com.weijun.keepalive_daemon.logE

/**
 * @author: weijun
 * date: 2023/7/6
 * description:
 */
class DaemonJobService : JobService() {

    companion object {
        const val JOB_ID = 1000
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        "DaemonJobService onStartCommand".logE()
        return START_STICKY
    }

    override fun onStartJob(params: JobParameters?): Boolean {
        if (Build.VERSION.SDK_INT >= 24) {
            DaemonKeepAlive.startScheduleService(applicationContext)
        }
        DaemonKeepAlive.startCoreService(applicationContext)
        return false
    }

    override fun onStopJob(params: JobParameters?): Boolean {
        return false
    }
}